package frame.laxcen.test;

import frame.laxcen.collection.ConstPair;
import frame.laxcen.request.Request_0010_10;
import frame.laxcen.module.RFIDReader;
import tcpclient.v2.RFIDClient;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.util.Optional;
import java.util.Set;

public class RFIDReader_Single_Read {

    public static void main(String[] args) throws IOException {

        RFIDReader reader = new RFIDReader(new RFIDClient(1 << 20, 1024));

        if(reader.tryConnect(new InetSocketAddress("192.168.1.116", 9090), 3000)) {

            System.out.println("连接成功！");

            Request_0010_10.RequestTemplate template = new Request_0010_10.RequestTemplate();

            template.useAntenna_1();

            template.standerSingleRead();

            Optional<ConstPair<String, String>> resultSet = reader.pointRead(new Request_0010_10(template),3000);

            System.out.println("进行单次读！");

            resultSet.ifPresent((e) -> System.out.println("Tid: [" + e.getValue1() + "] UserData: [" + e.getValue2() + "]"));

            if(reader.tryClose()) System.out.println("关闭连接！");
        }
    }
}
